package top.zackyoung.cloud.feign.controller;

import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zackyoung.cloud.feign.exam.FeignExamOne;
import top.zackyoung.cloud.feign.exam.FeignExamTwo;

import javax.annotation.Resource;

/**
 * @author ZackYoung
 * @version 1.0
 * @description
 * @date 2021/5/12 20:55
 */
@RestController
public class TestController {
    @Resource
    FeignExamOne feignExamOne;
    @Resource
    FeignExamTwo feignExamTwo;
    @Resource
    DiscoveryClient discoveryClient;

    @RequestMapping("/test1/{name}")
    public String test1(@PathVariable String name) {
        return feignExamOne.test(name);
    }
    @RequestMapping("/test2/{name}")
    public String test2(@PathVariable String name) {
        return feignExamTwo.test(discoveryClient.getInstances("user").get(0).getUri(),name);
    }
}
